package com.szgr.baoyin.comparator;

import com.szgr.baoyin.model.ReduceGoods;

import java.util.Comparator;

/**
 * Created by yang on 15/12/7.
 */
public class HomepageComparator implements Comparator {
    @Override
    public int compare(Object lhs, Object rhs) {
        if(lhs instanceof ReduceGoods && rhs instanceof ReduceGoods){
            ReduceGoods rgLhs = (ReduceGoods) lhs;
            ReduceGoods rgRhs = (ReduceGoods) rhs;
            double lhsPrice = Double.parseDouble(rgLhs.getGoods_price());
            double rhsPrice = Double.parseDouble(rgRhs.getGoods_price());
            if(lhsPrice > rhsPrice){
                return 1;
            }else if(lhsPrice < rhsPrice){
                return -1;
            }else{
                return 0;
            }
        }
        return 0;
    }
}
